﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ExecuteAssembly
{
    class Program
    {
        static void Main(string[] args)
        {
            //当前应用程序域信息
            Console.WriteLine("CurrentAppDomain start!");
            ShowMessage();

            //新的应用程序域对象
            AppDomain newAppDomain = AppDomain.CreateDomain("newAppDomain");
            newAppDomain.ExecuteAssembly("Example.exe");

            AppDomain.Unload(newAppDomain);
            Console.ReadKey();
        }

        public static void ShowMessage()
        {
            var message = string.Format(" CurrentThreadID is:{0}\tAppDomainID is:{1}", Thread.CurrentThread.ManagedThreadId, AppDomain.CurrentDomain.Id);
            Console.WriteLine(message);
        }
    }
}
